from datetime import datetime
from numba import jit


@jit
def calc(n, i, cols, diags, trans):
    if i == n:
        return 1
    else:
        rt = 0
        for j in range(n):
            col = 1 << j
            diag = 1 << (i - j + n - 1)
            tran = 1 << (i + j)

            if (col & cols) == 0 and (diag & diags) == 0 and (tran & trans) == 0:
                rt += calc(n, i+1, cols | col, diags | diag, trans | tran)
        return rt


start = datetime.now()
t = calc(15, 0, 0, 0, 0)
end = datetime.now()
print(t)
print(end - start)
print((end - start).seconds*1000+(end - start).microseconds/1000, "ms")
